﻿using System;
using System.Windows.Forms;
using AMatysiak.Methods;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace AMatysiakTest.Methods.TypeExtensions
{
    [TestClass]
    public class ToBoolTest
    {
        [TestMethod]
        public void checkTrue()
        {
            bool value = "true".ToBool();
            Assert.IsTrue(value);
        }

        [TestMethod]
        public void checkFalse()
        {
            bool value = "false".ToBool();
            Assert.IsFalse(value);
        }

        [TestMethod]
        public void check1()
        {
            bool value = "1".ToBool();
            Assert.IsTrue(value);
        }

        [TestMethod]
        public void check0()
        {
            bool value = "0".ToBool();
            Assert.IsFalse(value);
        }

        [TestMethod]
        public void checkChecked()
        {
            bool value = CheckState.Checked.ToString().ToBool();
            Assert.IsTrue(value);
        }

        [TestMethod]
        public void checkUnChecked()
        {
            bool value = CheckState.Unchecked.ToString().ToBool();
            Assert.IsFalse(value);
        }

        [TestMethod]
        [ExpectedException(typeof(FormatException))]
        public void checkEmpty()
        {
            "".ToBool();
        }
    }
}
